<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>Hello YhErp</title>
    <link rel="stylesheet" type="text/css" href="./css/api.css" />
    <link rel="stylesheet" type="text/css" href="./css/aui.css" />
    <link rel="stylesheet" type="text/css" href="./css/reset.css" />
    <link rel="stylesheet" type="text/css" href="./css/style.css" />
    <style type="text/css">
    </style>
</head>
<body>
    <div id="wrap" class="flex-wrap flex-vertical">
        <!-- <header id="header" class="aui-bar  aui-bar-nav">裕和ERP</header> -->
        <div id="main" class="flex-con">

        </div>
        <footer  class="aui-bar aui-bar-tab aui-padded-t-10 aui-padded-b-10" id="footer">
            <div class="aui-bar-tab-item aui-active"  tapmode onclick="openFrame('login')">
              <i class="aui-iconfont aui-icon-my"></i>
              <div class="aui-bar-tab-label">用户</div>
            </div>
            <div class="aui-bar-tab-item aui-active"  tapmode onclick="fnopenbarcode()">
              <i class="aui-iconfont aui-icon-cert"></i>
              <div class="aui-bar-tab-label">模式</div>
            </div>
        </footer>
    </div>
</body>
<script type="text/javascript" src="./script/api.js"></script>
<script type="text/javascript" src="./script/aui-tab.js"></script>
<script type="text/javascript" src="./script/common.js"></script>
<script type="text/javascript" src="./script/aui-toast.js"></script>
<script type="text/javascript">
    var user,toast;
    apiready = function(){
      //  $api.fixStatusBar($api.dom('header'));
        api.parseTapmode();
        user=$api.getStorage(cacheUser);
        toast = new auiToast({});
        if(user){
          if(user.username){
            openWinIndex('state-win');
            //openWinIndex('barcode-win');
          }else{
             openWinIndex('login');
          }
        }else{
             openWinIndex('login');
        }
    };

    function openWinIndex(type,params,reload) {
           var aniType='reveal';
      //if(api.systemType=='ios')aniType='cube';
      var reload=reload||false;
      api.openWin({
        name : type,
        url : './html/' + type + '.html',
        bounces : false,
        bgColor : 'rgba(242,242,242,1)',
        slidBackEnabled : false,
        animation : {
          type : aniType,
          subType : 'from-right',
          duration : 300
        },
        progress : {
          type : 'page',
          title : '温馨提示',
          text : '数据正在加载...',
          color : '#fff'
        },
        reload:reload,
        pageParam:params
      }, function(ret, errr) {
      });
    };

function openFrame(type){
  api.openFrame({
      name: type,
      url: './html/'+type+'.html',
      bounces: false,
      rect: {
          x: 0,
          y: 0,
          w: api.winWidth,
          h: $api.dom('#main').offsetHeight-$api.dom('#footer').offsetHeight
      }
   });
};

function fnopenbarcode(){

  user =$api.getStorage(cacheUser);
  if(user){
     openWinIndex('state-win');
  }else{
     api.toast({
         msg: '请登录操作',
         duration: 2000,
         location: 'midde'
     });

  }


};
</script>
</html>
